<%-- 
    Document   : view_alokasi
    Created on : Jul 31, 2012, 3:00:12 PM
    Author     : MiChi
--%>

<%@page import="dao.AlokasiDAOImpl"%>
<%@page import="entity.Alokasi"%>
<%@page import="java.util.List"%>
<%@page import="additional.Help"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <html>
    <head>
        <title> Alokasi Pekerjaan</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        
        <link href="../style/style.css" rel="stylesheet" type="text/css" />         
    </head>
    <body>
        <div id="central">
            <div id="menuatas">
                <marquee>
                    <h3> Welcome </h3>
                </marquee>
            </div>
            
            <div id="header">
                <% 
                    if(request.getSession().getAttribute("user") == null) {
                        out.write("<a href='/TR_Persistance_Alokasi_Karyawan/Logout'>LogOut</a>");
                    } else {
                        out.write("<a href='/TR_Persistance_Alokasi_Karyawan/login.jsp'>LogIn</a>");
                    }
                %> 
            </div>
            
            <ul id="navlist">
                <li><a id="n1" href="Home.jsp"><span>Home</span></a></li>
                <li><a id="n2" href="view_karyawan.jsp"><span>Karyawan</span></a></li>
                <li><a id="n3" href="view_pekerjaan.jsp"><span>Pekerjaan</span></a></li>
                <li><a id="n4" href="view_alokasi.jsp"><span>Alokasi Pekerjaan</span></a></li>                               
                <li><a id="n5" href="about.jsp"><span>About</span></a></li>                               
            </ul>
            <div id="content">                
                <div id="rightside">
                    <h1>Data Alokasi Karyawan</h1>
                    <hr>
                    <table border="0" width="100%">
                        <tr>
                            <th>ID Alokasi</th>
                            <th>ID Karyawan</th>
                            <th>Nama Karyawan</th>    
                            <th>ID Pekerjaan</th>
                            <th>Nama Pekerjaan</th>                            
                        </tr>
                        <%
                            try {
                                EntityManager em = Help.getEM();
                                //SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
                                
                                if (em != null) {
                                    List<Alokasi> listAlokasi = new AlokasiDAOImpl(em).gets();
                                    for (Alokasi p : listAlokasi) {
                                        out.write("<tr> \n");
                                        out.write("<td>" + p.getId() + "</td> \n");                                        
                                        out.write("<td>" + p.getKaryawan().getId() + "</td> \n");
                                        out.write("<td>" + p.getKaryawan().getNama().toUpperCase() + "</td> \n");
                                        out.write("<td>" + p.getPekerjaan().getId() + "</td> \n");
                                        out.write("<td>" + p.getPekerjaan().getNama().toUpperCase() + "</td> \n");                                                                                
                                        out.write("<td> <a href='/TR_Persistance_Alokasi_Karyawan/HapusAlokasi?id=" + p.getId() + "'>Hapus</a></td>");
                                        out.write("<td> <a href='edit_alokasi.jsp?id=" + p.getId() + "'>Edit</a></td>");
                                        out.write("</tr> \n");
                                    }
                                }

                            } catch (Exception e) {
                            }
                        %>
                    </table>            
                    <br>       
                      
                    <a href='add_alokasi.jsp'>Tambah Alokasi</a>
                </div>
                    
                <div id="footer">
                    <p>&COPY; copyright TR PERSISTENCE</p>
                </div>
    </body>
</html>
</html>
